//
//  AnswerViewController.m
//  Toyohu
//
//  Created by celia on 16/3/30.
//  Copyright (c) 2016年 celia. All rights reserved.
//

#import "AnswerViewController.h"
#import "AnswerCell.h"
static NSString *AnsReuseId = @"AnswerCell";
#define WIDTH self.view.bounds.size.width
#define HEIGHT self.view.bounds.size.height
@interface AnswerViewController ()<UITableViewDelegate,UITableViewDataSource>{
    UITableView *myTableView;
    NSMutableArray *array;
    NSMutableArray *timeArray;
}


@end

@implementation AnswerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBar.hidden = NO;
    self.view.backgroundColor = [UIColor colorWithRed:235/255.0 green:235/255.0 blue:241/255.0 alpha:1];
    myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,80,WIDTH,HEIGHT-64) style:UITableViewStylePlain];
    myTableView.delegate = self;
    myTableView.dataSource = self;
    [myTableView registerNib:[UINib nibWithNibName:@"AnswerCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:AnsReuseId];
    myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    self.automaticallyAdjustsScrollViewInsets=NO;
    
    [self.view addSubview:myTableView];
    myTableView.rowHeight = 238;
    
    UILabel *navLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 30)];
    navLabel.textColor = [UIColor whiteColor];
    navLabel.backgroundColor = [UIColor clearColor];
    navLabel.textAlignment = NSTextAlignmentCenter;
    navLabel.text = @"我回复的";
    navLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20];
    self.navigationItem.titleView = navLabel;
    
    
    //导航栏左边项
    UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeSystem];
    leftButton.frame = CGRectMake(0, 0, 10, 15);
    [leftButton setBackgroundImage:[UIImage imageNamed:@"ARROW---LEFT@2x"] forState:UIControlStateNormal];
    [leftButton addTarget:self action:@selector(goBackPreviousPage) forControlEvents:UIControlEventTouchDown];
    
    UIBarButtonItem *leftButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = leftButtonItem;
    
    
    
    array= [@[
              @"我也想不抱怨，可是真的有时候想想我们三姐弟怎么就有这样的父亲，真是够够的，父母赚钱不就是为了...",
              @"希望有从业者能现身说法~"
              ] mutableCopy];
    timeArray = [@[@"2016-03-26",@"2016-03-24"]mutableCopy];
    
    
    UIView *View = [[UIView alloc]initWithFrame:CGRectZero];
    myTableView.tableFooterView= View;
    // Do any additional setup after loading the view.
}

-(void)goBackPreviousPage{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark --UITableViewDeleGate DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
        
            AnswerCell *cell = [myTableView dequeueReusableCellWithIdentifier:AnsReuseId ];
            if (!cell) {
                cell = (AnswerCell *)[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier: AnsReuseId];
            }
            //cell.model = array[indexPath.row];
            cell.content.text = array[indexPath.row];
            cell.userImg.image = [UIImage imageNamed:@"tabbar_home_selected@2x"];
            cell.userName.text = @"一个演员的自我修养";
            cell.title.text = @"演员的自我修养";
            cell.time.text = timeArray[indexPath.row];
            cell.star.text  = @"1344";
            cell.counts.text = @"445";
            return cell;
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
